// Department management related APIs
import request from '@/utils/request'

// Get department list (pagination)
export function getDepartmentPage(params) {
  return request({
    url: '/api/depts',
    method: 'get',
    params
  })
}

// Get all departments
export const getAllDepartments = () => {
  return request({
    url: '/api/depts/list',
    method: 'get'
  })
}

// Add department
export function addDepartment(data) {
  return request({
    url: '/api/depts',
    method: 'post',
    data
  })
}

// Update department
export function updateDepartment(dept) {
  return request({
    url: '/api/depts',
    method: 'put',
    data: dept
  })
}

// Delete department
export function deleteDepartment(id) {
  return request({
    url: `/api/depts/${id}`,
    method: 'delete'
  })
}

// Get department tree
export function getDepartmentTree() {
  return request({
    url: '/api/depts/tree',
    method: 'get'
  })
}